package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.parm.EnterpriseParm;
import com.ruoyi.system.domain.parm.SysEnterpriseCertificationParm;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.SysEnterpriseCertification;
import com.ruoyi.system.service.ISysEnterpriseCertificationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 商家企业认证Controller
 * 
 * @author ruoyi
 * @date 2024-04-06
 */
@RestController
@RequestMapping("/certification")
public class SysEnterpriseCertificationController extends BaseController
{
    @Autowired
    private ISysEnterpriseCertificationService sysEnterpriseCertificationService;

    /**
     * 查询商家企业认证列表
     */
    @RequiresPermissions("system:certification:list")
    @GetMapping("/list")
    public TableDataInfo list(SysEnterpriseCertification sysEnterpriseCertification)
    {
        startPage();
        List<SysEnterpriseCertification> list = sysEnterpriseCertificationService.selectSysEnterpriseCertificationList(sysEnterpriseCertification);
        return getDataTable(list);
    }

    /**
     * 导出商家企业认证列表
     */
    @RequiresPermissions("system:certification:export")
    @Log(title = "商家企业认证", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysEnterpriseCertification sysEnterpriseCertification)
    {
        List<SysEnterpriseCertification> list = sysEnterpriseCertificationService.selectSysEnterpriseCertificationList(sysEnterpriseCertification);
        ExcelUtil<SysEnterpriseCertification> util = new ExcelUtil<SysEnterpriseCertification>(SysEnterpriseCertification.class);
        util.exportExcel(response, list, "商家企业认证数据");
    }

    /**
     * 获取商家企业认证详细信息
     */
    @RequiresPermissions("system:certification:query")
    @GetMapping(value = "/info")
    public AjaxResult getInfo(@RequestParam(name = "id",required = true) String  id)
    {
        return success(sysEnterpriseCertificationService.selectSysEnterpriseCertificationById(id));
    }



    /**
     * 商家企业认证申请审核
     */
    @ApiOperation(value = "商家企业认证申请审核")
    @RequiresPermissions("system:certification:edit")
    @Log(title = "商家企业认证", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/auditing")
    public AjaxResult auditing(@RequestBody EnterpriseParm enterpriseParm)
    {
        SysEnterpriseCertification  sysEnterpriseCertification=new SysEnterpriseCertification();
        sysEnterpriseCertification.setId(enterpriseParm.getId() );
        sysEnterpriseCertification.setStauts(enterpriseParm.getStauts() );
        sysEnterpriseCertification.setFailureReason(enterpriseParm.getFailureReason() );

        return toAjax(sysEnterpriseCertificationService.updateSysEnterpriseCertification(sysEnterpriseCertification));
    }

    /**
     * 删除商家企业认证
     */
    @RequiresPermissions("system:certification:remove")
    @Log(title = "商家企业认证", businessType = BusinessType.DELETE)
	@DeleteMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysEnterpriseCertificationService.deleteSysEnterpriseCertificationByIds(ids));
    }


}
